package controller

import (
	"encoding/json"
	"github.com/gin-gonic/gin"
	"github.com/wonderivan/logger"
	"payment/app/service"
	"payment/model"
)

func OrderCallback(c *gin.Context) {
	//data, error := c.Request.GetBody()
	//data
	rawData, _ := c.GetRawData()
	webHook := new(model.CallBackWebHook)
	err := json.Unmarshal(rawData, webHook)
	if err != nil {
		logger.Error("OrderCallback_JsonUnmarshal_Error | err=%v", err)
		c.JSON(400, &map[string]string{"msg": "json error"})
		return
	}
	logger.Debug("OrderCallback_Data json=%v", string(rawData))
	service.GetPayEntryService().WebHookCallback(webHook)
	c.JSON(200, &map[string]string{"test": "1"})
}
